 
 	<?php
		function set_val($obj, $val, $return='echo')
		{
			if(isset($obj))
				if(isset($obj->$val))
					if($return=='echo')
						echo($obj->$val);
					else
						return $obj->$val;
		}
	?>
 
				<div><br>
					<form id="form" class="block-content form" action="<?php echo site_url('admin/permission/save')?>" method="post">
						<input type="hidden" id="id" name="id" value="<?php set_val($perm,'id')?>" />
						
						<div class="_100">
							<p><label for="controller">Controller/Module</label>
							<input id="controller" name="controller" class="required" type="text" value="<?php set_val($perm,'controller')?>" /></p>
						</div>
						
						<div class="_50">
							<p><label for="function">Function</label>
							<input id="function" name="function" class="required" type="text" value="<?php set_val($perm,'function')?>" /></p>
						</div>
						
						<div class="_50">
							<p><label for="alias_name">Alias Name</label>
							<input id="alias_name" name="alias_name" class="required" type="text" value="<?php set_val($perm,'alias_name')?>" /></p>
						</div>
																	
						<div class="_100">
							<p><label for="description">Description</label>
							<textarea id="description" name="description" class="" rows="2" cols="40"><?php set_val($perm,'description')?></textarea>
						</div>




						<div class="clear"></div>
						<div class="block-actions">
							<ul class="actions-left">
								<li><a class="button red" id="reset-validate-form" href="javascript:void(0);">Reset</a></li>
							</ul>
							<ul class="actions-right">
								<li><input type="submit" class="button" value="Save!"></li>
							</ul>
						</div>
					</form>

				</div>
				
				
	<script type="text/javascript">
						
		
	$().ready(function() {
		
		/** Submit Form **/
		$("#form").validate({
				rules:{},
				messages: {},
				submitHandler: function(form) {
				   //submit
				$.post("<?php echo site_url('admin/permission/save')?>", $("#form").serialize(),
					function(data){
						if(data){
							
							newdata = $.parseJSON(data);
							
							if(newdata.error){
								Gtheme = 'error';
								
								$.each(newdata.msg, function(index) {
									$.jGrowl(newdata.msg[index], { theme: Gtheme,position:'center'  });
								});

							}
							else{
								Gtheme = 'saved';
								$.jGrowl(newdata.msg, { theme: Gtheme,position:'center'  });

								location.reload();
							}

						}
						else{
							$.jGrowl("Error!", { theme: 'error' });
						}
					});
				}
			});
		/** End Submit Form **/
		
		});
		
		
    </script>

